#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int testUpdateCoins(struct gameState *state) {
	int i, oldCoinCount, player, bonus;
	double rnd;
	
	for (player = 0; player < state->numPlayers; player ++) {
		updateCoins(player, state, 0);
		oldCoinCount = state->coins;
		printf("\tTesting for player %d: ", player);
		for (i=0;i<=99;i++){
			rnd = Random();
			bonus = Random()*10;
			if ((rnd > 0.7) && (bonus <= oldCoinCount)) { bonus *= -1; }
			updateCoins(player, state, bonus);
			assert (oldCoinCount + bonus == state->coins);
		}
		printf(" passed all 100 coin updates!\n");
	}
	return 0;
}

int main() {
    
    int seed = 1000;
    int numPlayer = 3;
    
	struct gameState G;
	struct gameState *state = &G;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
		   sea_hag, tribute, smithy};

	initializeGame(numPlayer, k, seed, &G);
	printf("Testing updateCoin():\n");
	testUpdateCoins(state);
	
	printf("   updateCoin() Passed all tests!\n");
	

    return 0;
}

